global $wgMemc;
$fname = 'DifferenceEngine::getDiffBody';
wfProfileIn( $fname );
-
+ // Should part of this diff be hidden?
+ $deleted = false;
+ if ( $this->mOldRev && $this->mOldRev->isDeleted(Revision::DELETED_TEXT) ) {
+ $deleted = true;
+ } else if ( $this->mNewRev && $this->mNewRev->isDeleted(Revision::DELETED_TEXT) ) {
+ $deleted = true;
+ }
// Cacheable?
$key = false;
if ( $this->mOldid && $this->mNewid ) {
if ( !$this->mRefreshCache ) {
$difftext = $wgMemc->get( $key );
if ( $difftext ) {
- wfIncrStats( 'diff_cache_hit' );
- $difftext = $this->localiseLineNumbers( $difftext );
- $difftext .= "\n<!-- diff cache key $key -->\n";
- wfProfileOut( $fname );
- return $difftext;
+ // If this diff should be hidden, kill the cache!
+ if( $deleted ) {
+ $wgMemc->delete( $key );
+ $difftext = false;
+ } else {
+ wfIncrStats( 'diff_cache_hit' );
+ $difftext = $this->localiseLineNumbers( $difftext );
+ $difftext .= "\n<!-- diff cache key $key -->\n";
+ wfProfileOut( $fname );
+ return $difftext;
+ }
}
} // don't try to load but save the result
}
if ( !$this->loadText() ) {
wfProfileOut( $fname );
return false;
- } else if ( $this->mOldRev && !$this->mOldRev->userCan(Revision::DELETED_TEXT) ) {
- return '';
- } else if ( $this->mNewRev && !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) {
- return '';
}
$difftext = $this->generateDiffBody( $this->mOldtext, $this->mNewtext );
// Save to cache for 7 days
// Only do this for public revs, otherwise an admin can view the diff and a non-admin can nab it!
- if ( $this->mOldRev && $this->mOldRev->isDeleted(Revision::DELETED_TEXT) ) {
- wfIncrStats( 'diff_uncacheable' );
- } else if ( $this->mNewRev && $this->mNewRev->isDeleted(Revision::DELETED_TEXT) ) {
+ if ( $deleted ) {
wfIncrStats( 'diff_uncacheable' );
} else if ( $key !== false && $difftext !== false ) {
wfIncrStats( 'diff_cache_miss' );
*/
function getUserText() {
if( $this->isDeleted( self::DELETED_USER ) ) {
- return "";
+ return false;
} else {
return $this->mUserText;
}
*/
function getComment() {
if( $this->isDeleted( self::DELETED_COMMENT ) ) {
- return "";
+ return false;
} else {
return $this->mComment;
}
*/
function getText() {
if( $this->isDeleted( self::DELETED_TEXT ) ) {
- return "";
+ return false;
} else {
return $this->getRawText();
}
*/
function revText() {
if( !$this->userCan( self::DELETED_TEXT ) ) {
- return "";
+ return false;
} else {
return $this->getRawText();
}